package com.robot.orders.client;

import com.alibaba.fastjson.JSON;
import com.robot.orders.client.impl.MemberClientImpl;
import com.robot.orders.pojo.client.Member;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

/**
 * @author lin
 */
@Component
@FeignClient(value = "robot-member", fallback = MemberClientImpl.class)
public interface MemberClient {
    /**
     * 通过id查询会员
     *
     * @param id
     * @return
     */
    @GetMapping(value = "member/third/findMemberById/{id}", produces = "application/json; charset=utf-8")
    public String thirdFindMemberById(@PathVariable String id);

    /**
     * 查找可用的用户
     *
     * @param id
     * @return
     */
    @RequestMapping(value = "member/third/findEnableMemberById/{id}", produces = "application/json; charset=utf-8")
    String thirdFindEnableMemberById(@PathVariable String id);

    /**
     * 查找会员推荐人名字
     *
     * @param recommendId
     * @return
     */
    @RequestMapping(value = "member/third/findRecommenderName/{recommendId}", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
    public String thirdFindRecommenderName(@PathVariable String recommendId);

    /**
     * 查找会员推荐人数
     *
     * @param id
     * @return
     */
    @RequestMapping(value = "member/third/findRecommendedNumber/{id}", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
    public Integer thirdFindRecommendedNumber(@PathVariable String id);


    /**
     * 传入对象来修改member
     *
     * @param member
     */
    @PutMapping(value = "member/third/updateMemberByMember", produces = "application/json; charset=utf-8")
    @Transactional(rollbackFor = Exception.class)
    public void thirdUpdateMemberByMember(@RequestBody String member);
}
